/**
* @author Max Rupplin
* @date 4-21-08
* @file ddas_workgen.C
*/

#ifndef DDAS_XML_HANDLER_HPP
#define DDAS_XML_HANDLER_HPP

#include "ddas_definitions.h"
#include "DDAS_Client_Result_Data.hpp"

#include "sched_msgs.h"
#include "validate_util.h"

#include <xercesc/dom/DOM.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>

#include <string>
#include <stdexcept>

extern "C"
{
	#include "lip.h"
}

XERCES_CPP_NAMESPACE_USE

/// This class is responsible for parsing and writing XML documents for the DDAS project
class DDAS_XML_Handler
{
	public:
		DDAS_XML_Handler();
		
		~DDAS_XML_Handler();

		int DDAS_XML_Handler::initResultDocument(DOMDocument** doc, int job_id);

		int DDAS_XML_Handler::appendDataRows(DOMDocument* doc, DDAS_Client_Result_Data* results);

		int DDAS_XML_Handler::serializeDOMDocument(DOMDocument* doc, char* URL);

		int DDAS_XML_Handler::appendCoefficients(DOMDocument* doc, DDAS_Client_Result_Data* results);

		int DDAS_XML_Handler::createResultDocument( int job_id, int num_results, DDAS_Client_Result_Data* results );

		DDAS_Client_Result_Data* DDAS_XML_Handler::parseResultData( const RESULT& result );

		char* DDAS_XML_Handler::getCustomFileAsString( verylong start, verylong end, int numX, int numY, int numRows, int numResults, int jobID );

        	int DDAS_XML_Handler::writeCustomFile( const char* file_path, verylong start, verylong end, int numX, int numY, int numRows, int numResults, int jobID );

        	int DDAS_XML_Handler::writeCommonFile( const char* source_file_path, const char* dest_file_path );
};

#endif

